<!DOCTYPE html><html lang="zh-CN"><head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>localeData() | Moment.js &#x6587;&#x6863;</title>
  <link rel="stylesheet" href="static/css/style.css">
  <link rel="shortcut icon" href="http://momentjs.cn/static/img/moment-favicon.png">
  <link rel="stylesheet" href="static/css/atom-one-light.min.css">
</head>
<body class="is-moment">
  <div class="hero hero-oneline">
    <div class="hero-centered">
      <h1>localeData()</h1>
    </div>
  </div>
  <div id="api-section-__FILENAME__">
    <div id="content" class="clearfix">
  
      <div id="column1" data-id="__ID__" class="interior">
        <header>
          <!-- <h1>localeData()</h1> -->
          <div id="gtoc">
            <ul>
              <!-- <li>v</li> -->
              <li>
                <a href="index.html#/i18n/locale-data/" name="toc">&#x8FD4;&#x56DE;&#x4E0A;&#x5C42;&#x6587;&#x6863;</a>
              </li>
              <li style="border: none;">
                <a href="javascript:window.open('https://github.com/momentjscn/moment-docs-cn/edit/master/moment/06-i18n/08-locale-data.md');" rel="nofollow" target="_blank">&#x63D0;&#x4EA4;&#x4FEE;&#x6539;</a>
              </li>
              <!-- <li>
                <a href="/search__SEARCH_PARAM__" name="toc">搜索</a>
              </li> -->
            </ul>
          </div>
          <hr>
        </header>

        <div id="biz_item"></div>
  
        <div id="apicontent">
          <div id="content_left">
							<div class="docs-method-signature">
								<pre><code class="language-js">localeData = moment.localeData()
localeData.months(Moment)
localeData.months()
localeData.monthsShort(Moment)
localeData.monthsShort()
localeData.monthsParse(String)
localeData.weekdays(Moment)
localeData.weekdays()
localeData.weekdays(Boolean)      ## &#x65B0;&#x589E;&#x4E8E; 2.24.0&#xFF0C;&#x6309;&#x8BED;&#x8A00;&#x73AF;&#x5883;&#x5BF9;&#x5DE5;&#x4F5C;&#x65E5;&#x8FDB;&#x884C;&#x6392;&#x5E8F;&#x3002;
localeData.weekdaysShort(Moment)
localeData.weekdaysShort()
localeData.weekdaysShort(Boolean) ## &#x65B0;&#x589E;&#x4E8E; 2.24.0&#xFF0C;&#x6309;&#x8BED;&#x8A00;&#x73AF;&#x5883;&#x5BF9;&#x5DE5;&#x4F5C;&#x65E5;&#x8FDB;&#x884C;&#x6392;&#x5E8F;&#x3002;
localeData.weekdaysMin(Moment)
localeData.weekdaysMin()
localeData.weekdaysMin(Boolean)   ## &#x65B0;&#x589E;&#x4E8E; 2.24.0&#xFF0C;&#x6309;&#x8BED;&#x8A00;&#x73AF;&#x5883;&#x5BF9;&#x5DE5;&#x4F5C;&#x65E5;&#x8FDB;&#x884C;&#x6392;&#x5E8F;&#x3002;
localeData.weekdaysParse(String)
localeData.longDateFormat(String)
localeData.isPM(String)
localeData.meridiem(Number, Number, Boolean)
localeData.calendar(String, Moment)
localeData.relativeTime(Number, Boolean, String, Boolean)
localeData.pastFuture(Number, String)
localeData.ordinal(Number)
localeData.preparse(String)
localeData.postformat(String)
localeData.week(Moment)
localeData.invalidDate()
localeData.firstDayOfWeek()
localeData.firstDayOfYear()
</code></pre>

							</div>
<p>&#x53EF;&#x4EE5;&#x901A;&#x8FC7; <code>moment.localeData(key)</code> &#x51FD;&#x6570;&#x8BBF;&#x95EE;&#x5F53;&#x524D;&#x52A0;&#x8F7D;&#x7684;&#x8BED;&#x8A00;&#x73AF;&#x5883;&#x7684;&#x5C5E;&#x6027;&#x3002;
&#x5B83;&#x8FD4;&#x56DE;&#x5F53;&#x524D;&#x8BED;&#x8A00;&#x73AF;&#x5883;&#x6216;&#x5177;&#x6709;&#x7ED9;&#x5B9A;&#x952E;&#x7684;&#x8BED;&#x8A00;&#x73AF;&#x5883;&#xFF1A;</p>
<pre><code class="language-javascript">// &#x83B7;&#x53D6;&#x5F53;&#x524D;&#x7684;&#x8BED;&#x8A00;&#x73AF;&#x5883;
var currentLocaleData = moment.localeData();
var frLocaleData = moment.localeData(&apos;fr&apos;);
</code></pre>
<p>&#x8FD4;&#x56DE;&#x7684;&#x5BF9;&#x8C61;&#x5177;&#x6709;&#x4EE5;&#x4E0B;&#x65B9;&#x6CD5;&#xFF1A;</p>
<pre><code class="language-javascript">localeData.months(aMoment);  // aMoment &#x7684;&#x5B8C;&#x6574;&#x6708;&#x4EFD;&#x540D;&#x79F0;
localeData.monthsShort(aMoment);  // aMoment &#x7684;&#x7B80;&#x77ED;&#x6708;&#x4EFD;&#x540D;&#x79F0;
localeData.monthsParse(longOrShortMonthString);  // &#x8FD4;&#x56DE;&#x8F93;&#x5165;&#x7684;&#x6708;&#x4EFD; id (0 &#x81F3; 11)
localeData.weekdays(aMoment);  // aMoment &#x7684;&#x5B8C;&#x6574;&#x5DE5;&#x4F5C;&#x65E5;&#x540D;&#x79F0;
localeData.weekdaysShort(aMoment);  // aMoment &#x7684;&#x7B80;&#x77ED;&#x5DE5;&#x4F5C;&#x65E5;&#x540D;&#x79F0;
localeData.weekdaysMin(aMoment);  // aMoment &#x7684;&#x6700;&#x5C0F;&#x5DE5;&#x4F5C;&#x65E5;&#x540D;&#x79F0;
localeData.weekdaysParse(minShortOrLongWeekdayString);  // &#x8FD4;&#x56DE;&#x8F93;&#x5165;&#x7684;&#x5DE5;&#x4F5C;&#x65E5; id (0 &#x81F3; 6)
localeData.longDateFormat(dateFormat);  // &#x8FD4;&#x56DE;&#x7F29;&#x5199;&#x7684;&#x65E5;&#x671F;&#x65F6;&#x95F4;&#x683C;&#x5F0F;&#xFF08;LT&#x3001;L&#x3001;LL &#x7B49;&#xFF09;&#x7684;&#x5B8C;&#x6574;&#x683C;&#x5F0F;
localeData.isPM(amPmString);  // &#x5982;&#x679C; amPmString &#x4EE3;&#x8868; PM&#xFF0C;&#x5219;&#x8FD4;&#x56DE; true
localeData.meridiem(hours, minutes, isLower);  // &#x8FD4;&#x56DE;&#x5927;&#x5199;/&#x5C0F;&#x5199;&#x7684;&#x7279;&#x5B9A;&#x65E5;&#x671F;&#x65F6;&#x95F4;&#x7684; am/pm &#x5B57;&#x7B26;&#x4E32;
localeData.calendar(key, aMoment);  // &#x8FD4;&#x56DE;&#x7528;&#x4E8E;&#x65E5;&#x5386;&#x8868;&#x793A;&#x7684;&#x683C;&#x5F0F;&#x3002;&#x952E;&#x662F; &apos;sameDay&apos;&#x3001;&apos;nextDay&apos;&#x3001;&apos;lastDay&apos;&#x3001;&apos;nextWeek&apos;&#x3001;&apos;prevWeek&apos;&#x3001;&apos;sameElse&apos; &#x4E4B;&#x4E00;
localeData.relativeTime(number, withoutSuffix, key, isFuture);  // &#x8FD4;&#x56DE;&#x76F8;&#x5BF9;&#x65F6;&#x95F4;&#x7684;&#x5B57;&#x7B26;&#x4E32;&#xFF0C;&#x952E;&#x662F; &apos;s&apos;&#x3001;&apos;m&apos;&#x3001;&apos;mm&apos;&#x3001;&apos;h&apos;&#x3001;&apos;hh&apos;&#x3001;&apos;d&apos;&#x3001;&apos;dd&apos;&#x3001;&apos;M&apos;&#x3001;&apos;MM&apos;&#x3001;&apos;y&apos;&#x3001;&apos;yy&apos; &#x4E4B;&#x4E00;&#x3002;&#x5F53; number &#x4E3A; 1 &#x65F6;&#x4E3A;&#x5355;&#x4E2A;&#x5B57;&#x6BCD;
localeData.pastFuture(diff, relTime);  // &#x6839;&#x636E;&#x5DEE;&#x5F02;&#x5C06; relTime &#x5B57;&#x7B26;&#x4E32;&#x8F6C;&#x6362;&#x4E3A;&#x8FC7;&#x53BB;&#x6216;&#x672A;&#x6765;&#x7684;&#x5B57;&#x7B26;&#x4E32;
localeData.ordinal(number);  // &#x5C06;&#x6570;&#x5B57;&#x8F6C;&#x6362;&#x4E3A;&#x5E8F;&#x6570;&#x5B57;&#x7B26;&#x4E32; 1-&gt; 1st
localeData.preparse(str);  // &#x5728;&#x89E3;&#x6790;&#x6BCF;&#x4E2A;&#x8F93;&#x5165;&#x5B57;&#x7B26;&#x4E32;&#x4E4B;&#x524D;&#x8C03;&#x7528;
localeData.postformat(str);  // &#x5728;&#x683C;&#x5F0F;&#x5316;&#x6BCF;&#x4E2A;&#x5B57;&#x7B26;&#x4E32;&#x540E;&#x8C03;&#x7528;
localeData.week(aMoment);  // &#x8FD4;&#x56DE; aMoment &#x7684;&#x5468;&#x5E74;
localeData.invalidDate();  // &#x8FD4;&#x56DE; &apos;Invalid date&apos; &#x7684;&#x7FFB;&#x8BD1;
localeData.firstDayOfWeek();  // 0-6 (&#x661F;&#x671F;&#x65E5;&#x81F3;&#x661F;&#x671F;&#x516D;)
localeData.firstDayOfYear();  // 0-15 &#x7528;&#x4E8E;&#x5224;&#x65AD;&#x5E74;&#x4EFD;&#x7684;&#x7B2C;&#x4E00;&#x5468;
</code></pre>
<p>&#x6709;&#x5173; <code>firstDayOfYear</code> &#x7684;&#x8BE6;&#x7EC6;&#x4FE1;&#x606F;&#x53EF;&#x4EE5;&#x5728;<a href="javascript:window.open('http://nodejs.cn/s/4R8WBy');" target="_blank" rel="nofollow">&#x81EA;&#x5B9A;&#x4E49;</a>&#x7AE0;&#x8282;&#x4E2D;&#x67E5;&#x770B;&#x3002;</p>
					</div>
          <div id="content_right">
							<div class="docs-method-signature">
								<pre><code class="language-js">localeData = moment.localeData()
localeData.months(Moment)
localeData.months()
localeData.monthsShort(Moment)
localeData.monthsShort()
localeData.monthsParse(String)
localeData.weekdays(Moment)
localeData.weekdays()
localeData.weekdays(Boolean)      ## Added 2.24.0, sorts weekdays by locale
localeData.weekdaysShort(Moment)
localeData.weekdaysShort()
localeData.weekdaysShort(Boolean) ## Added 2.24.0, sorts weekdays by locale
localeData.weekdaysMin(Moment)
localeData.weekdaysMin()
localeData.weekdaysMin(Boolean)   ## Added 2.24.0, sorts weekdays by locale
localeData.weekdaysParse(String)
localeData.longDateFormat(String)
localeData.isPM(String)
localeData.meridiem(Number, Number, Boolean)
localeData.calendar(String, Moment)
localeData.relativeTime(Number, Boolean, String, Boolean)
localeData.pastFuture(Number, String)
localeData.ordinal(Number)
localeData.preparse(String)
localeData.postformat(String)
localeData.week(Moment)
localeData.invalidDate()
localeData.firstDayOfWeek()
localeData.firstDayOfYear()
</code></pre>

							</div>
<p>You can access the properties of the currently loaded locale through the
<code>moment.localeData(key)</code> function. It returns the current locale or a locale
with the given key:</p>
<pre><code class="language-javascript">// get current locale
var currentLocaleData = moment.localeData();
var frLocaleData = moment.localeData(&apos;fr&apos;);
</code></pre>
<p>The returned object has the following methods:</p>
<pre><code class="language-javascript">localeData.months(aMoment);  // full month name of aMoment
localeData.monthsShort(aMoment);  // short month name of aMoment
localeData.monthsParse(longOrShortMonthString);  // returns month id (0 to 11) of input
localeData.weekdays(aMoment);  // full weekday name of aMoment
localeData.weekdaysShort(aMoment);  // short weekday name of aMoment
localeData.weekdaysMin(aMoment);  // min weekday name of aMoment
localeData.weekdaysParse(minShortOrLongWeekdayString);  // returns weekday id (0 to 6) of input
localeData.longDateFormat(dateFormat);  // returns the full format of abbreviated date-time formats LT, L, LL and so on
localeData.isPM(amPmString);  // returns true iff amPmString represents PM
localeData.meridiem(hours, minutes, isLower);  // returns am/pm string for particular time-of-day in upper/lower case
localeData.calendar(key, aMoment);  // returns a format that would be used for calendar representation. Key is one of &apos;sameDay&apos;, &apos;nextDay&apos;, &apos;lastDay&apos;, &apos;nextWeek&apos;, &apos;prevWeek&apos;, &apos;sameElse&apos;
localeData.relativeTime(number, withoutSuffix, key, isFuture);  // returns relative time string, key is on of &apos;s&apos;, &apos;m&apos;, &apos;mm&apos;, &apos;h&apos;, &apos;hh&apos;, &apos;d&apos;, &apos;dd&apos;, &apos;M&apos;, &apos;MM&apos;, &apos;y&apos;, &apos;yy&apos;. Single letter when number is 1.
localeData.pastFuture(diff, relTime);  // convert relTime string to past or future string depending on diff
localeData.ordinal(number);  // convert number to ordinal string 1 -&gt; 1st
localeData.preparse(str);  // called before parsing on every input string
localeData.postformat(str);  // called after formatting on every string
localeData.week(aMoment);  // returns week-of-year of aMoment
localeData.invalidDate();  // returns a translation of &apos;Invalid date&apos;
localeData.firstDayOfWeek();  // 0-6 (Sunday to Saturday)
localeData.firstDayOfYear();  // 0-15 Used to determine first week of the year.
</code></pre>
<p>Details about <code>firstDayOfYear</code> can be found in the <a href="#/customization/dow-doy/" target="_blank" rel="nofollow">customization</a> section.</p>
					</div>
          <div></div>
        </div>
      </div>
    </div>
  </div>
  
  <script src="static/js/highlight.min.js"></script>
  <script src="static/js/javascript.min.js"></script>
  <script>hljs.initHighlightingOnLoad();</script>
  <script>var _hmt = _hmt || []; (function () { var hm = document.createElement("script"); hm.src = "//hm.baidu.com/hm.js?7a7f78c805fbacc7e075d34f153031aa"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })();</script>

  <style>
    .hero-centered {
      margin: 0;
          margin-left: 10px;
    }
#gtoc ul {
  list-style: none;
  margin-left: 0;
  line-height: 1.5rem;
  padding: 0;
}
#gtoc>ul>li {
  display: inline;
  border-right: 1px solid #000;
  margin-right: .4rem;
  padding-right: .4rem;
}
#gtoc>ul>li>a {
  color: #61b2a7;
}
#content_left {
  width: 49%;float: left;border-right: 1px solid #eee;    padding-right: 2%;
}
#content_right {
float: left;width: 48%;margin-left: 3%;
}
#column1 {
  padding: 0 2rem;
}
  </style>


</body></html>